# -*- coding: utf-8 -*-
from flask import request, url_for
import time


def url_for_other_page(page):
    args = request.view_args.copy()
    r_args = request.args

    for k in r_args:
        args[k] = r_args[k]

    args['page'] = page
    args['_external'] = True
    return url_for(request.endpoint, **args)


def format_date(value, format="%Y-%m-%d"):

    return value.strftime(format)


def register_filter(app):
    app.jinja_env.globals['url_for_other_page'] = url_for_other_page
    app.jinja_env.filters['format_date'] = format_date